package fourzerofour.guoshixu.day01;

import java.util.Scanner;

public class Question4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //用户输入的数
        int num;
        //总和
        int sum = 1;
        //出入语句
        String inputStr = "1";
        //输入不为奇数，便循环到用户输入奇数为止，由于用户必须要先输入一次，所以此处采用do...while循环
        do {
            System.out.println("请输入一个奇数：");
            num = scanner.nextInt();
        }while (num%2==0);

        for (int i=2;i<num;i++){
            if(i%2==1){
                sum += i;
                inputStr += "+" + i;
            }
        }
        inputStr += "的结果为" + sum;

        System.out.println(inputStr);

    }
}
